/**
 * gvSIG. Desktop Geographic Information System.
 *
 * Copyright (C) 2007-2012 gvSIG Association.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA  02110-1301, USA.
 *
 * For any additional information, do not hesitate to contact us
 * at info AT gvsig.com, or visit our website www.gvsig.com.
 */
package org.gvsig.titleblock.impl;

import java.util.ArrayList;

import org.gvsig.andami.PluginServices;
import org.gvsig.app.project.documents.layout.fframes.FFrameText;
import org.gvsig.app.project.documents.layout.fframes.IFFrame;
import org.gvsig.titleblock.IFFrameItem;

/**
 * Represents a FFrameItem
 * @author Violeta
 * @version $Id$
 */
public class FFrameItem implements IFFrameItem {
	
	private IFFrame frame;

	
	/**
	 * Initializes the frame
	 * @param frame
	 */
	public FFrameItem(IFFrame frame) {
		this.frame=frame;
	}
	
	/**
	 * Searchs for a text in the frame and returns it
	 */
	public String toString(){
		if (frame==null){
			return PluginServices.getText(this, "empty_item");
		}
		String name=frame.getNameFFrame();
		if (frame instanceof FFrameText){
			ArrayList texts=((FFrameText)frame).getText();
			if (texts.size()>0){
				name+= " : "+texts.get(0);
			}
		}
		return name;
	}
	
	/**
	 * Returns the frame
	 */
	public IFFrame getFFrame() {
		return frame;
	}
}
